package com.hjxy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hjxy.dao.CourseDao;
import com.hjxy.pojo.Course;
import com.hjxy.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName:
 * @description:
 * @author: yh
 * @createDate: 2020/9/29
 * @version: 1.0
 */
@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    private CourseDao courseDao;
    //获取课程的全部信息
    @Override
    public List<Course> geyAll() {
        return courseDao.queryAll();
    }
//分页
    @Override
    public PageInfo<Course> getCoursePage(Integer currentPage, Integer pageSize) {
       //准备拦截mybatis后续的查询
        PageHelper.startPage(currentPage,pageSize);
        List<Course> courseList=courseDao.queryAll();
        //pageinfo内部计算总共有多少页
        PageInfo<Course> pageinfo = new PageInfo<>(courseList);
        return pageinfo;
    }

    @Override
    public Course getone(Integer courseId) {
        Course course=courseDao.queryById(courseId);
        System.out.println(course);
        return course;
    }
//编辑后，加入数据库中
    @Override
    public boolean modifyone(Course course) {
        return courseDao.updateByCourse(course);
    }
//逻辑删除
    @Override
    public boolean deletelj(Course course) {
        return courseDao.deleteLJ(course);
    }
/*添加课程 */
    @Override
    public boolean addClass(Course course) {
        return courseDao.addClass(course);
    }

    @Override
    public List<Course> searchAll(String search) {
        return courseDao.searchAll(search);
    }
}
